<?php

/**
 * Simple configuration object
 */
class Config {
    private $_config = array();
    
    /**
     * Set the configuration variables in this object
     */
    public function setAll($array) {
        $this->_config = $array;
    }
    
    /**
     * Get a configuration variable by name
     * Reports an error if the key does not exist
     */
    public function get($key) {
        return $this->_config[$key];
    }
    
    /**
     * Get a specific variable by name, returning null if the key does not exist
     */
    public function getDefault($key, $default) {
        if(array_key_exists($key, $this->_config)) {
            return $this->_config[$key];
        } else {
            return $default;
        }
    }
    
    /**
     * Sets the specified key to the given value
     */
    public function set($key, $value) {
        $this->_config[$key] = $value;
    }
}
